package com.takeoff.boot.controller;

import com.takeoff.boot.entity.UserInfo;
import com.takeoff.boot.service.UserInfoService;
import com.takeoff.boot.vo.UserInfoVo;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: TODO
 * @Author: Take-off
 * @Date: 2024/8/30 3:53 PM
 * @Param
 * @return
 * @Version: 1.0
 **/
@RestController
@RequestMapping("/api/v1/user")
@AllArgsConstructor
public class UserInfoController{

    private final UserInfoService userInfoService;

    /**
     * 保存用户信息
     * @return
     */
    @PostMapping("/saveUser")
    public String saveUser(@RequestBody UserInfoVo userInfoVo){
        UserInfo userInfo = new UserInfo();
        BeanUtils.copyProperties(userInfoVo,userInfo);
        userInfoService.save(userInfo);
        return "SUCCESS";
    }
    @PostMapping("/detail")
    public UserInfo detail(@RequestBody UserInfo userInfo) {
        UserInfo userInfo1 = userInfoService.selectByName(userInfo.getName());
        return userInfo1;
    }

}
